package com.taotao.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.taotao.pojo.TbItem;
import com.taotao.pojo.TbItemDesc;
import com.taotao.web.service.ItemService;

@RequestMapping("/item")
@Controller
public class ItemController {

	@Autowired
	private ItemService itemService;
	
	@RequestMapping(method = RequestMethod.GET ,value = "{itemId}")
	public ModelAndView itemDetail(@PathVariable(value="itemId")Long itemId) {
		ModelAndView mView = new ModelAndView("item");
		TbItem item = this.itemService.queryById(itemId);
		mView.addObject("item", item);
		
	    //查询商品描述数据
        TbItemDesc itemDesc = this.itemService.queryItemDescByItemId(itemId);
        mView.addObject("itemDesc", itemDesc);
        
        String itemParam = this.itemService.queryItemParamByItemId(itemId);
        mView.addObject("itemParam", itemParam);
		return mView;
	}	
	
}
